package com.fin.quant.web.controller;

import com.fin.quant.app.service.DividendService;
import com.fin.quant.app.service.vo.DividendDto;
import com.fin.quant.rpc.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class DividendController {

    @Autowired
    private DividendService dividendService;

    /**
     * 用户关注的资产的分红统计
     * @return
     */
    @RequestMapping("/api/user/dividends")
    public Result<List<DividendDto>> dividends(Long userId) {
        List<DividendDto> dividendList = dividendService.getUserDividend(userId);
        return Result.createSuccessResult(dividendList);
    }

    /**
     * 市场中的资产的分红统计
     * @return
     */
    @RequestMapping("/api/market/dividends")
    public Result<List<DividendDto>> dividends(String sort) {
        List<DividendDto> dividendList = dividendService.getMarketDividend();
        return Result.createSuccessResult(dividendList);
    }

}
